package com.dognessnetwork.operation.controller;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dognessnetwork.operation.baseservice.DeviceInfoService;
import com.dognessnetwork.operation.dognecklace.domain.DeviceInfo;
import com.dognessnetwork.operation.dognecklace.dto.Response;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value="/deviceinfo")
@Api("swaggerDemoController相关的api")
public class DeviceInfoJsonController {
	private static final Logger logger = LoggerFactory.getLogger(DeviceInfoJsonController.class);
	private @Autowired DeviceInfoService deviceInfoService;
	
	@ApiOperation(value = "DeviceInfo添加", notes = "数据库插入device_info表")
	//@ApiImplicitParam(name = "deviceInfo", value = "设备信息详细实体deviceInfo", required = true, dataType = "DeviceInfo")	
	@PostMapping(value="/add")
	public Response add(DeviceInfo deviceInfo) {
		logger.info("\n{}",deviceInfo);
		Response Response = deviceInfoService.save(deviceInfo);
		return Response;
	}
	
	@ApiOperation(value = "DeviceInfo删除", notes = "通过id删除deviceinfo")
	@ApiImplicitParam(name = "id", value = "设备信息详细实体deviceInfo的id", required = true, dataType = "Long")	
	@PostMapping(value="/delete_by_id")
	public void deleteById(Long id) {
		
		deviceInfoService.deleteById(id);
	}
	
	@ApiOperation(value = "DeviceInfo通過id查詢數據", notes = "查詢数据库device_info表")
    //@ApiImplicitParam(name = "id", value = "设备信息详细实体deviceInfo的id",  required = true, dataType = "Long")
	@PostMapping(value="/find_by_id")
	public Response findById(@RequestParam("id")Long id) {
		logger.info("\n{}",id);
		Response response = deviceInfoService.findById(id);
		return response;
	}
}
